import request from '@/utils/request'

const api = {
    moduleapi: '/system/org'
}

export function treeselect(params) {
    return request({
        url: api.moduleapi + '/treeselect',
        method: 'get',
        params
    })
}

export function getList(parameter) {
    return request({
        url: api.moduleapi + '/list',
        method: 'get',
        params: parameter
    })
}

export function saveModule(parameter) {
    return request({
        url: api.moduleapi + '/save',
        method: 'post',
        data: parameter,
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

export function updateModule(parameter) {
    return request({
        url: api.moduleapi,
        method: 'put',
        data: parameter,
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

export function delModule(parameter) {
    return request({
        url: api.moduleapi,
        method: 'Delete',
        params: parameter
    })
}

// 初始化机构祖籍数据
export function initOrgAncestors()
{
    return request({
        url:api.moduleapi + "/initOrgAncestors",
        method:"post"
    })
}

//获取当前登录用户单位下的机构列表
export function getCompanyTree(params)
{
    return request({
        url:api.moduleapi + "/getCompanyTree",
        method:"get",
        params
    })
}

//根据父级id获取机构列表
export function getOrgListByParentId(params)
{
    return request({
        url:api.moduleapi + "/getOrgListByParentId",
        method:"get",
        params
    }) 
}


//导出机构
export function exportOrg(data)
{
    return request({
        url:api.moduleapi + "/exportOrg",
        method:"post",
        data,
        responseType: 'blob'
    })
}


export const qbglExport = api.qbgl + '/export'